package com.ruoyi.web.controller.manage;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.manage.domain.SuitManagement;
import com.ruoyi.manage.service.ISuitManagementService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: wwy
 * @Date: 2021/3/2 10:34
 */
@Api("门户端婚纱套系查询")
@RestController
@RequestMapping("/api")
public class AppSuitManagementController extends BaseController {
    @Autowired
    private ISuitManagementService suitManagementService;
    /**
     * 查询婚纱套系列表
     */
    @GetMapping("/suitManagementList")
    public TableDataInfo list(SuitManagement suitManagement) {
        startPage();
        List<SuitManagement> list = suitManagementService.selectSuitManagementList(suitManagement);
        for (SuitManagement management : list) {
            management.setCoverImageOb(JSONObject.parseObject(management.getCoverImage(),List.class));
        }
        return getDataTable(list);
    }

    /**
     * 获取婚纱套系详细信息
     */
    @GetMapping(value = "/suitManagement/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(suitManagementService.selectSuitManagementById(id));
    }
}
